Next:
Duff’s device
, Previous:
Coroutines
, Up:
Index
Pointer to Member
Pointer to Member
클래스에 멤버의 상대 주소를 저장할 수 있는 클래스 지역 포인터
double
complex
::
*
member_selector
=&
complex
::
i
;
complex
c
(
7.0
,
8.0
)
,
c2
(
9.0
)
;
complex
*
p
=&
c
;
cout
<<
"
c's selected member is
"
<<
c
.
*
member_selector
<<
'\n'
;
cout
<<
"
p's selected member is
"
<<
p
->*
member_selector
<<
'\n'
;
member_selector
=&
complex
::
r
;
p
=&
c2
;
cout
<<
"
c's selected member is
"
<<
c
.
*
member_selector
<<
'\n'
;
cout
<<
"
p's selected member is
"
<<
p
->*
member_selector
<<
'\n'
;